package java6;

import java.util.Scanner;

public class Code074 {
	public static void main(String[] args) {
		System.out.println("***********************************");
		System.out.println("请选择购买的商品编号:");
		System.out.println("1.T 恤\t2.网球鞋\t3.网球拍");
		System.out.println("***********************************\n\n");
		Scanner input = new Scanner(System.in);
		int s=1;int m=1;
		double sum1= 0;
		double sum2= 0;
		double sum3= 0;
		double sum;
		String a = "y";
		while(a.equals("y")){
			if(m==1){
				System.out.print("请输入商品编号        ");
			}
			if(input.hasNextInt()){
				int num1 = input.nextInt();
				switch(num1){
				case 1:
					System.out.print("请输入购买数量        ");
					if(input.hasNextInt()){
						int num2 = input.nextInt();
						sum1= sum1+245.0*num2;
						System.out.println("T 恤  ￥245.0\t数量 "+num2+"\t合计￥"+sum1);
						System.out.println("是否继续(y/n)");
						String b = input.next();
						a=(String)b;
						break;
					}else{
						System.out.println("数量应为整数！");
						m=2;
						break;
					}
				case 2:
					System.out.print("请输入购买数量        ");
					if(input.hasNextInt()){
						int num2 = input.nextInt();
						sum2= sum2+570.0*num2;
						System.out.println("网球鞋  ￥570.0\t数量 "+num2+"\t合计￥"+sum2);
						System.out.println("是否继续(y/n)");
						String b = input.next();
						a=(String)b;
						break;
					}else{
						System.out.println("数量应为整数！");
						m=2;
						break;
					}
				case 3:
					System.out.print("请输入购买数量        ");

					if(input.hasNextInt()){
						int num2 = input.nextInt();
						sum3= sum3+245.0*num2;
						System.out.println("网球拍  ￥3000.0\t数量 "+num2+"\t合计￥"+sum3);
						System.out.println("是否继续(y/n)");
						String b = input.next();
						a=(String)b;
						break;
					}else{
						System.out.println("数量应为整数！");
						m=2;
						break;
					}
				default:
					System.out.println("输入编号不存在！");
					break;
				}
			}
			else{
				if(m==1){
					System.out.println("输入编号不存在！");
					s=2;
					break;
				}
			}
		}
		if(s==1){
			System.out.println("折扣:0.8");	
			sum = sum1+sum2+sum3;
			System.out.println("应付金额:"+sum);
			System.out.print("实付金额:      ");
			if(input.hasNextDouble()){
				double money=input.nextDouble();
				if(money>=sum){
					System.out.println("找钱"+(money-sum));
				}else{
					System.out.println("付的钱不够！");
				}
			}else{
				System.out.println("对不起，不收假币！");
			}
		}

	}
}
